<?php
include_once("../configs/admin.config.inc.php");	//--> admin global var
include_once("db.inc.php");							//--> db global var
include_once("Smarty.class.php");					//--> out template
include_once("Operation.php");						//--> Operation
include_once("Pic.php");							//--> Pic
require_once("controlHeader.php");					//--> system control header
include_once("Strings.php");						//--> String
include_once("InfoClass.php");						//--> Info Class
include_once("PicUpload.php");						//--> PicUpload

$objOperate		= new Operation($sessionImpl->session['lan']);			//--> Operation
$objPic			= new Pic($sessionImpl->session['lan'], $uid);			//--> Pic
$objString  	= new Strings();										//--> String
$objInfoClass 	= new InfoClass($sessionImpl->session['lan'], $uid);		//--> Info Class
$objPicUpload	= new PicUpload($sessionImpl->session['lan'], $uid);		//--> PicUpload

$error_message = '';

$arrOperate 	= $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
$arrOperateInfo = $objOperate->arrGetOPInfo($arrOperate);

if($objPic->isAdmin($gid)){
	$where = " ORDER BY id DESC";
}else{
	$where = " WHERE userid=$uid ORDER BY id DESC";
}

$arrDataList = $objPic->lists($arrOperate, $where, $page, DISPLAY_DATA_SIZE, '');
if(is_array($arrDataList)){
	foreach($arrDataList as $key=>$value){
		$total = $objPicUpload->getTotalFromID($arrOperate, $value['id']);
		$arrDataList[$key]['uploadFileCount'] = $total;
		
		$arrDataInfo = $objInfoClass->getFromID($arrOperate, $value['classid']);
		if(is_array($arrDataInfo)){
			$arrDataList[$key]['className'] = $arrDataInfo['name'];
		}
	}
}

/*----- out html -----*/
$smarty = new Smarty();		//----- out template
$smarty->template_dir = TEMPLATE_DIR;
$smarty->compile_dir  = COMPILE_DIR;

$smarty->assign('error_message', $error_message);
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);

$smarty->assign('selfFileName', $objOperate->strGetSelfFileName());
$smarty->assign('arrOperateInfo', $arrOperateInfo);

$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $objFF->pagenav);

$smarty->display('listPic.htm');
?>
